home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50b Issue 142 (CD142b) (August 1998).iso / handson / Java / sc20form.jar / com / supercede / forms / SuperCedePanel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-01-28  |  5.7 KB  |  238 lines

  1. package com.supercede.forms;
  2.  
  3. import com.supercede.beans.Support;
  4. import java.applet.Applet;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Graphics;
  8. import java.awt.Panel;
  9. import java.awt.Point;
  10. import java.io.IOException;
  11. import java.io.InvalidObjectException;
  12. import java.io.ObjectInputStream;
  13. import java.io.Serializable;
  14. import java.util.Vector;
  15.  
  16. public class SuperCedePanel extends Panel implements SuperCedeDesignContainer, SuperCedeContainerListener, Support, Serializable {
  17.    SuperCedeRuntimeInfo runtimeInfo = new SuperCedeRuntimeInfo();
  18.    SuperCedeDesignInfo designInfo = new SuperCedeDesignInfo();
  19.    transient boolean designMode = false;
  20.    transient DesignModeListener formListener = null;
  21.    transient Vector scContainerListeners = null;
  22.    boolean shadowEnabled = super.isEnabled();
  23.    Point shadowLocation = new Point(0, 0);
  24.    private static final long serialVersionUID = 1013082004010516613L;
  25.    private static final int _version = 1;
  26.    private int version = 1;
  27.  
  28.    public final void initializeThis(Vector var1) throws IOException, ClassNotFoundException, ClassCastException, SuperCedeInvalidStateException {
  29.       this.designInfo = null;
  30.       this.runtimeInfo = null;
  31.       SuperCedeHelper.runTimeConstructor(this, var1);
  32.       ((Component)this).setLocation(this.shadowLocation);
  33.       this.validateObject();
  34.    }
  35.  
  36.    public Component[] getContainedComponents() {
  37.       return ((Container)this).getComponents();
  38.    }
  39.  
  40.    public void initializeFrom(SuperCedeContainer var1) throws ClassCastException, SuperCedeInvalidStateException {
  41.       try {
  42.          this.setDesignMode(((SuperCedeDesignContainer)var1).isDesignMode());
  43.          this.setFormListener(((SuperCedeDesignContainer)var1).getFormListener());
  44.          this.runtimeInfo = var1.getRuntimeInfo();
  45.          this.designInfo = ((SuperCedeDesignContainer)var1).getDesignInfo();
  46.          SuperCedeHelper.convertContainer((Container)var1, this);
  47.          if (!this.isDesignMode()) {
  48.             this.runtimeInfo = null;
  49.             this.designInfo = null;
  50.          }
  51.       } catch (ClassCastException var3) {
  52.          throw var3;
  53.       }
  54.    }
  55.  
  56.    public SuperCedeDesignInfo getDesignInfo() {
  57.       return this.designInfo;
  58.    }
  59.  
  60.    public SuperCedeRuntimeInfo getRuntimeInfo() {
  61.       return this.runtimeInfo;
  62.    }
  63.  
  64.    public void addComponent(Component var1, Object var2) {
  65.       this.addComponent(var1, var2, -1);
  66.    }
  67.  
  68.    public void addComponent(Component var1, Object var2, int var3) {
  69.       this.add(var1, var2, var3);
  70.       this.runtimeInfo.addLayoutConstraints(var1, var2);
  71.    }
  72.  
  73.    public void add(Component var1, Object var2, int var3) {
  74.       super.add(var1, var2, var3);
  75.       if (((Component)this).isVisible() && var1 instanceof Applet) {
  76.          ((Applet)var1).start();
  77.       }
  78.  
  79.    }
  80.  
  81.    public void removeComponent(int var1) {
  82.       this.removeComponent(((Container)this).getComponent(var1));
  83.    }
  84.  
  85.    public void removeComponent(Component var1) {
  86.       this.runtimeInfo.removeLayoutConstraints(var1);
  87.       this.remove(var1);
  88.    }
  89.  
  90.    public void remove(Component var1) {
  91.       if (((Component)this).isVisible() && var1 instanceof Applet) {
  92.          ((Applet)var1).stop();
  93.       }
  94.  
  95.       super.remove(var1);
  96.    }
  97.  
  98.    public boolean isEnabled() {
  99.       return this.shadowEnabled;
  100.    }
  101.  
  102.    public void setEnabled(boolean var1) {
  103.       this.shadowEnabled = var1;
  104.       if (!this.isDesignMode()) {
  105.          super.setEnabled(var1);
  106.       }
  107.  
  108.    }
  109.  
  110.    public void paint(Graphics var1) {
  111.       if (this.formListener != null) {
  112.          this.formListener.paint(var1);
  113.       }
  114.  
  115.       super.paint(var1);
  116.    }
  117.  
  118.    public void addNotify() {
  119.       if (this.formListener != null) {
  120.          this.formListener.setupParentHWND();
  121.       }
  122.  
  123.       super.addNotify();
  124.       if (this.formListener != null) {
  125.          this.formListener.addedPeer();
  126.       }
  127.  
  128.    }
  129.  
  130.    public void removeNotify() {
  131.       if (this.formListener != null) {
  132.          this.formListener.removingPeer();
  133.       }
  134.  
  135.       super.removeNotify();
  136.    }
  137.  
  138.    public Object getLayoutConstraints(Component var1) {
  139.       return this.runtimeInfo.getLayoutConstraints(var1);
  140.    }
  141.  
  142.    public Object getLayoutConstraints(int var1) {
  143.       return this.getLayoutConstraints(((Container)this).getComponent(var1));
  144.    }
  145.  
  146.    public void setDesignMode(boolean var1) {
  147.       this.designMode = var1;
  148.    }
  149.  
  150.    public boolean isDesignMode() {
  151.       return this.designMode;
  152.    }
  153.  
  154.    public void setFormListener(DesignModeListener var1) {
  155.       this.formListener = var1;
  156.    }
  157.  
  158.    public DesignModeListener getFormListener() {
  159.       return this.formListener;
  160.    }
  161.  
  162.    public void doPostSerializeProcessing(boolean var1) {
  163.       Container var2 = ((Component)this).getParent();
  164.       if (var2 instanceof SuperCedeContainer) {
  165.          ((SuperCedeContainer)var2).addSuperCedeContainerListener(this);
  166.       }
  167.  
  168.    }
  169.  
  170.    public void containerShutdown(SuperCedeContainerEvent var1) {
  171.       if (this.scContainerListeners != null) {
  172.          synchronized(this){}
  173.  
  174.          Vector var2;
  175.          try {
  176.             var2 = (Vector)this.scContainerListeners.clone();
  177.          } catch (Throwable var5) {
  178.             throw var5;
  179.          }
  180.  
  181.          for(int var3 = 0; var3 < var2.size(); ++var3) {
  182.             ((SuperCedeContainerListener)var2.elementAt(var3)).containerShutdown(var1);
  183.          }
  184.       }
  185.  
  186.    }
  187.  
  188.    public void addSuperCedeContainerListener(SuperCedeContainerListener var1) {
  189.       synchronized(this){}
  190.  
  191.       try {
  192.          if (this.scContainerListeners == null) {
  193.             this.scContainerListeners = new Vector();
  194.          }
  195.  
  196.          this.scContainerListeners.addElement(var1);
  197.       } catch (Throwable var4) {
  198.          throw var4;
  199.       }
  200.  
  201.    }
  202.  
  203.    public void removeSuperCedeContainerListener(SuperCedeContainerListener var1) {
  204.       synchronized(this){}
  205.  
  206.       try {
  207.          this.scContainerListeners.removeElement(var1);
  208.       } catch (Throwable var4) {
  209.          throw var4;
  210.       }
  211.  
  212.    }
  213.  
  214.    public void setVisible(boolean var1) {
  215.       if (!var1) {
  216.          SuperCedeHelper.setAppletVisibility(this, this.isDesignMode(), false);
  217.       }
  218.  
  219.       super.setVisible(var1);
  220.       if (var1) {
  221.          SuperCedeHelper.setAppletVisibility(this, this.isDesignMode(), true);
  222.       }
  223.  
  224.    }
  225.  
  226.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  227.       var1.defaultReadObject();
  228.  
  229.       try {
  230.          SuperCedeHelper.doDeserializationProcessing(this);
  231.       } catch (SuperCedeInvalidStateException var2) {
  232.       }
  233.    }
  234.  
  235.    public void validateObject() throws InvalidObjectException {
  236.    }
  237. }
  238.